<template name='person_admin'>
	<view>
		<view style="width: 100%;height: 90%;display: flex;justify-content: center;align-items: center;">
			<view style="width: 96%;position: absolute; top:0; background-color: #FFFFFF;box-shadow: 1px 1px 5px #C0C0C0;padding-top: 20upx;">
				<view style="width: 90%;padding: 30upx;display: flex;flex-direction: row;justify-content: center;align-items: center;border-bottom: 1px solid #EBEEF5;">
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{count.count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								通过项目里程碑总数
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{count.start_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								正在筹款里程碑数
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{count.end_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								筹款完毕里程碑
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 25%;">
							<view style="display: flex;flex-direction: row;padding: 10upx;align-items: center;">
								<view class="num" style="font-size: 55px;margin-right: 15upx;font-weight: 500;">
									{{count.other_count}}
								</view>
								<view style="font-size: 30px;color: #999999;">
									个
								</view>
							</view>
							<view style="font-size: 15px;font-weight: 550;">
								待审与其他状态里程碑数
							</view>
						</view>
				</view>
				
				<!-- 数据列表 -->
				<view style="color: #606270;display: flex;width: 100%;justify-content: center;font-size: 15px;flex-direction: column;align-items: center;">
					<view style="border-bottom: 1px solid #EBEEF5;display: flex;flex-direction: row;width: 90%;background-color: #F5F7FA;padding: 10upx;">
						<!-- <checkbox :checked="choose_all_" @click="choose_all" style="transform:scale(0.7);width: 5%;"/> -->
						<view style="width: 15%;">
							项目ID
						</view>
						<view style="width: 15%;">
							项目名称 
						</view>
						<view style="width: 20%;">
							里程碑目标
						</view>
						<view style="width: 15%;">
							里程碑金额
						</view>
						<view style="width: 15%;">
							已筹集金额
						</view>
						<view style="width: 10%;">
							里程碑状态
						</view>
						
						<view style="width: 20%;">
							操作
						</view>
					</view>
						<view v-for="(item,index) in pageList" :key=index class="list_detail" style="width: 90%; display: flex;justify-content: center;align-items: center;">
						<!-- <checkbox :value="item.id.toString()" :checked='checkbox' style="transform:scale(0.7);width: 5%;"/> -->
						<view style="width: 15%;">
							{{item.task_id}} 
						</view>
						<view style="width: 15%;">
							{{item.task_name}} 
						</view>
						<view style="width: 20%;">
							里程碑{{item.lcb_index+1}}: {{item.text}} 
						</view>
						<!-- <view style="width: 23%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin-right: 1%;"> -->
						<view style="width: 15%;word-wrap: break-word; margin-left: 10px; ">
							{{item.price}}
						</view>
						<view style="width: 15%;">
							{{item.get_price || 0}}
						</view> 
						<view style="width: 10%; color: red; font-weight: 800;" >
							
							{{ item.status === 1 ? '正在筹集' : (item.status === 2 ? '已集齐' : (item.status === 0 ? '暂未开始/已暂停' : (item.status === undefined ? '暂未开始' : '已放款'))) }}
						</view>
						<view style="width: 20%;display: flex;flex-direction: row;">
							
							<!-- <view class="alter" style=" margin-left: 5px;">
								查看资料
							</view> -->
							<view  @click="call(item)"  v-if="item.status==2" class="alter" style=" margin-left: 5px">
								联系放款
							</view>
							<view @click="start_lcb(item,1)" v-else-if="item.status==0 || item.status== undefined" class="alter" style=" margin-left: 5px ;color: red;">
								开始里程
							</view>
							<view @click="start_lcb(item,0)"  v-else-if="item.status==1" class="alter" style=" margin-left: 5px">
								暂停里程
							</view>
							<view v-else class="alter" style=" margin-left: 5px">
								已完结
							</view>
						</view>
					</view>
					
				</view>
				<!-- 数据列表end -->
			</view>
		</view>
		
	</view>
	
</template>

<script>
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	import global from "@/common/global.js"
	export default{
		name:'lcb_amdin',
		components: {
			uniPopup
		},
		data(){
			return{
				c_lcb: '',
				c_id: '',
				// 添加的菜品内容
				
				
			}
		},
		 // 此处定义传入的数据
		props: {
			count: {
			    value: {}
			},
			pageList: {
			    type: Array,
			    value: null
			},
		},
		
		methods:{
			call(item){
				var user_id = item.user_id
				uni.request({
					url:global.baseUrl+'api/user/money',
					method: "POST",
					data:{
						user_id: user_id,
					},					
					success: function (res) {
						console.log(res.data)
							if(res.data.code == 10000){
								uni.showModal({
									title:'联系方式：',
									content: res.data.data.username +"："+res.data.data.mobile,
									confirmText: '确定',
									cancelText: '取消',
									success: function (res) {
											if (res.confirm) {
											} else if (res.cancel) {
												console.log('用户点击取消');
											}
											
										}
								})
							}else{
								uni.showToast({
									icon: 'none',
									title:'操作失败',
									duration: 2000
								})
							}
						}
					})
			},
			start_lcb(item,status){
				uni.showModal({
					title:'请确认信息：',
					content: '里程： '+ item.task_name +'\n里程碑：'+ item.lcb_index+1 + '：'+item.text +'\n金额：'+item.price,
					confirmText: '确认操作',
					cancelText: '取消操作',
					success: function (res) {
							if (res.confirm) {
								uni.request({
									url:global.baseUrl+'api/task/lcb_admin_status',
									method: "POST",
									data:{
										task_id: item.task_id,
										lcb_index: item.lcb_index,
										status: status
									},					
									success: function (res) {
										console.log(res)
											if(res.data.code == 10000){
												uni.showToast({
													icon: 'none',
													title:'操作成功',
													duration: 2000
												})
												
												  setTimeout(() => {
												    uni.navigateTo({
												        url: '/pages/admin/admin'
												      });
												  }, 1500);
											}else{
												uni.showToast({
													icon: 'none',
													title:'操作失败',
													duration: 2000
												})
											}
										}
									})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
							
						}
				})
			},
			alter_cancel(){
				this.$refs.popup.close()
			},
			alter_sure(){
					var that = this
					console.log(that.c_id)
					uni.showModal({
						title:'请确认',
						content: '项目里程碑: '+ this.c_lcb ,
						confirmText: '确认通过',
						cancelText: '取消操作',
						success: function (res) {
								if (res.confirm) {
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
								that.$refs.popup.close()
							}
					})
					
				
			},
			close(){
				this.$refs.popup.close()
			},
			confirm0(){
				this.input_confirm = 0
				console.log(this.input_confirm)
			},
			confirm1(){
				this.input_confirm = 1
				console.log(this.input_confirm)
			},
			confirm2(){
				this.input_confirm = 2
				console.log(this.input_confirm)
			},
			confirm3(){
				this.input_confirm = 3
				console.log(this.input_confirm)
			},
			confirm4(){
				this.input_confirm = 4
				console.log(this.input_confirm)
			},
			confirm5(){
				this.input_confirm = 5
				console.log(this.input_confirm)
			},
			confirm7(){
				this.input_confirm = 7
				console.log(this.input_confirm)
			},
			confirm8(){
				this.input_confirm = 8
				console.log(this.input_confirm)
			},
			confirm9(){
				this.input_confirm = 9
				console.log(this.input_confirm)
			},
			
			alter:function(e){
				this.$refs.popup.open()
				console.log(e)
				this.c_id = e.id
				this.c_lcb = e.lcb
			},
			
			change_page:function(e){
				console.log(e)
				var that = this
				if(e != '...'){
					that.NowPage = e
					that.checkbox = false
					that.checkbox_status =[]
					if(e >= 4&&e <= that.PageNum-3){
						that.pageList=[]
						that.pageList.push(1)
						that.pageList.push('...')
						for(var i = e-2;i<e+3;i++){
							that.pageList.push(i)
						}
						that.pageList.push('...')
						that.pageList.push(that.PageNum)
					}else{
						if(e<4){
							that.pageList=[]
							for(var i = 1;i < 7;i++){
								that.pageList.push(i)
							}
							that.pageList.push('...')
							that.pageList.push(that.PageNum)
						}else{
							that.pageList=[]
							that.pageList.push(1)
							that.pageList.push('...')
							for(var i = that.PageNum-5;i < that.PageNum+1;i++){
								that.pageList.push(i)
							}
						}
					}
					uni.request({
						url:'https://hn216.api.yesapi.cn/',
						method: "POST",
						data:{
							model_name:'food_info',
							where:'[["food_name", "LIKE","'+that.search_word+'"]]',
							app_key:'0B4163C86181759DD5DE6C761AF719A5',
							service:'App.Table.FreeQuery',
							perpage:5, //每一页12个数据
							page:e, //第几页
							// order: ["id DESC"],
						},					
						success: function (res) {
								// console.log(res.data.data.list)
								that.PersonList = res.data.data.list
								console.log(that.PersonList)
							}
						})
				}
				
			},
			page_delete:function(){
				var that = this
				if(that.NowPage<=1){
					alert('已经是首页了！')
				}else{
					that.NowPage = that.NowPage-1
					if(that.NowPage >= 4&&that.NowPage <= that.PageNum-3){
						that.pageList=[]
						that.pageList.push(1)
						that.pageList.push('...')
						for(var i = that.NowPage-2;i<that.NowPage+3;i++){
							that.pageList.push(i)
						}
						that.pageList.push('...')
						that.pageList.push(that.PageNum)
					}else{
						if(that.NowPage<4){
							that.pageList=[]
							for(var i = 1;i < 7;i++){
								that.pageList.push(i)
							}
							that.pageList.push('...')
							that.pageList.push(that.PageNum)
						}else{
							that.pageList=[]
							that.pageList.push(1)
							that.pageList.push('...')
							for(var i = that.PageNum-5;i < that.PageNum+1;i++){
								that.pageList.push(i)
							}
						}
					}
					uni.request({
						url:'https://hn216.api.yesapi.cn/',
						method: "POST",
						data:{
							model_name:'food_info',
							where:'[["food_name", "LIKE","'+that.search_word+'"]]',
							app_key:'0B4163C86181759DD5DE6C761AF719A5',
							service:'App.Table.FreeQuery',
							perpage:5, //每一页12个数据
							page:that.NowPage, //第几页
							// order: ["id DESC"],
						},					
						success: function (res) {
								// console.log(res.data.data.list)
								that.PersonList = res.data.data.list
								console.log(that.PersonList)
							}
						})
				}
			},
			page_add:function(){
				var that = this
				if(that.NowPage>=that.PageNum){
					console.log('不合格')
					alert('已经是尾页了！')
				}else{
					that.NowPage = that.NowPage+1
					if(that.NowPage >= 4&&that.NowPage <= that.PageNum-3){
						that.pageList=[]
						that.pageList.push(1)
						that.pageList.push('...')
						for(var i = that.NowPage-2;i<that.NowPage+3;i++){
							that.pageList.push(i)
						}
						that.pageList.push('...')
						that.pageList.push(that.PageNum)
					}else{
						if(that.NowPage<4){
							that.pageList=[]
							for(var i = 1;i < 7;i++){
								that.pageList.push(i)
							}
							that.pageList.push('...')
							that.pageList.push(that.PageNum)
						}else{
							that.pageList=[]
							that.pageList.push(1)
							that.pageList.push('...')
							for(var i = that.PageNum-5;i < that.PageNum+1;i++){
								that.pageList.push(i)
							}
						}
					}
					uni.request({
						url:'https://hn216.api.yesapi.cn/',
						method: "POST",
						data:{
							model_name:'food_info',
							where:'[["food_name", "LIKE","'+that.search_word+'"]]',
							app_key:'0B4163C86181759DD5DE6C761AF719A5',
							service:'App.Table.FreeQuery',
							perpage:5, //每一页12个数据
							page:that.NowPage, //第几页
							// order: ["id DESC"],
						},					
						success: function (res) {
								// console.log(res.data.data.list)
								that.PersonList = res.data.data.list
								console.log(that.PersonList)
							}
						})
				}
			}
				
		}
	}
</script>

<style>
	.input_image{
		height: 100upx;
		width: 100upx;
		margin-left: 20upx;
		border: 1px solid #DCDFE6;
	}
	.input_confirm_image{
		height: 100upx;
		width: 100upx;
		margin-left: 20upx;
		border: 1px solid #1890FF;
	}
	.input_image:hover{
		border: 1px solid #C8C7CC;
	}
	.alter_sure{
		margin-left: auto;height: 15upx;width: 15upx;padding: 5upx;
		border: 1px solid #FFFFFF;
	}
	.alter_sure:hover{
		border: 1px solid #C8C7CC;
	}
	.add_color{
		background-color: #1890FF;
		
	}
	.add_color:hover{
		background-color: #46A6FF;
	}
	.admin_pic{
		width: 180upx;
		height: 50upx;
		padding: 20upx;
	}
	.admin_pic:hover{
		background-color: #2C405A;
	}
	.arrow{
		height: 20upx;
		width: 20upx;
		
		margin-left: auto;
	}
	.arrow1{
		height: 18upx;
		width: 18upx;
		
	}
	.detail{
		padding: 20upx 20upx 20upx 40upx;
		width: 160upx;
		display: flex;
		flex-direction: row;
		color: #FFFFFF;
		font-size: 15px;
		align-items: center;
		
	}
	.detail:hover{
		background-color: #1890FF;
	}
	.list_detail{
		border-bottom: 1px solid #EBEEF5;display: flex;flex-direction: row;width: 100%;padding: 10upx;
	}
	.list_detail:hover{
		background-color: #F5F7FA;
	}
	.alter{
		color: #1890FF;
	}
	.alter:hover{
		text-decoration: underline;
		color: #DD524D;
	}
	.delete{
		color: #1890FF;margin-left: 10upx;
	}
	.delete:hover{
		text-decoration: underline;
		color: #DD524D;
	}
	.left{
		background-color: #F4F4F5;
		width: 15upx;
		height: 15upx;
		padding: 10upx;
	}
	.page{
		color: #FFFFFF;
		background-color: #1890FF;
		width: 32upx;
		height: 32upx;
		font-size: 15px;
		border-radius: 3upx;
		text-align: center;
		justify-content: center;
		display: flex;
		align-items: center;
		margin-left: 10upx;
	}
	.nopage{
		color: #FFFFFF;
		background-color: #F4F4F5;
		width: 32upx;
		height: 32upx;
		font-size: 15px;
		border-radius: 3upx;
		text-align: center;
		justify-content: center;
		display: flex;
		align-items: center;
		margin-left: 10upx;
		color: #606270;
	}
	.right{
		margin-left: 10upx;
		background-color: #F4F4F5;
		width: 15upx;
		height: 15upx;
		padding: 10upx;
	}
	.input_account{
		padding: 5upx 15upx 5upx 15upx;border: 1px solid #DCDFE6;width: 250upx;font-size: 13px;margin-left: 20upx;
	}
	.input_account:hover{
		border: 1px solid #C8C7CC;
	}
	.input_account1{
		padding: 5upx 15upx 5upx 15upx;border: 1px solid #DCDFE6;width: 227upx;font-size: 13px;margin-left: 20upx;
	}
	.input_confirm{
		border: 1px solid #1890FF;
		padding: 5upx 15upx 5upx 15upx;width: 250upx;font-size: 13px;margin-left: 20upx;
	}
	
	.back_color{
		background-color: #FF4D4F;
	}
	.back_color:hover{
		background-color: #FF7172;
	}
	.show_image{
		width: 50%;height: 100upx;
	}
	.show_image:hover{
		transform: scale(1.3);
	}
</style>
